﻿// Fill out your copyright notice in the Description page of Project Settings.

#include "BSiteLearnGameModeBase.h"
#include "Engine.h"
#include "SphereBase.h"

ABSiteLearnGameModeBase::ABSiteLearnGameModeBase()
{
	PrimaryActorTick.bCanEverTick = true;

	
}

void ABSiteLearnGameModeBase::BeginPlay()
{
	Super::BeginPlay();

	CurrentWorld = GetWorld();
	ASphereBase * player = Cast<ASphereBase>(CurrentWorld->GetFirstPlayerController()->GetPawn());
	if (player)
	{
		CurrentPlayer = player;
		CurrentPlayerPos = CurrentPlayer->GetActorLocation();
	}
}

void ABSiteLearnGameModeBase::Tick(float DealtTime)
{
	Super::Tick(DealtTime);
}

void ABSiteLearnGameModeBase::ResetPlayerLocation()
{
	CurrentPlayer->SetActorLocation(CurrentPlayerPos);
	CurrentPlayer->SphereMeshComp->SetPhysicsAngularVelocityInDegrees(FVector(0, 0, 0));
	CurrentPlayer->SphereMeshComp->SetPhysicsLinearVelocity(FVector(0, 0, 0));
}

void ABSiteLearnGameModeBase::ResetPlayerLocation(FVector newLocation)
{
	CurrentPlayer->SetActorLocation(newLocation);
	CurrentPlayer->SphereMeshComp->SetPhysicsAngularVelocityInDegrees(FVector(0, 0, 0));
	CurrentPlayer->SphereMeshComp->SetPhysicsLinearVelocity(FVector(0, 0, 0));
}

void ABSiteLearnGameModeBase::SetCurrentPlayerPos(FVector newlocation)
{
	if (newlocation != FVector(0,0,0))
	{
		CurrentPlayerPos = newlocation;
	}
}
